package cn.java71.springboot.demo1.ctrl;

import cn.java71.springboot.demo1.entity.Page;
import cn.java71.springboot.demo1.entity.Subject;
import cn.java71.springboot.demo1.service.SubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author oldliu
 * @since 1.0
 */
@RestController
@RequestMapping("subject")
public class SubjectController {
    @Autowired
    private SubjectService subjectService;
    @GetMapping("search")
    public Page<Subject> search(int pageNo, @RequestParam(name = "pageSize",defaultValue = "10",required = false) int pageSize, String subjectname){
//        List<Subject> datas=new ArrayList<>();
//        for(int i=1+pageNo;i<=pageNo+10;i++){
//            datas.add(new Subject(pageNo+i,"java"+i+"手册",40+pageNo,4L));
//        }
//        return datas;
        return subjectService.page(pageNo, pageSize, subjectname);
    }
}
